package com.itheima.stock.controller;

import com.itheima.stock.pojo.SysRole;
import com.itheima.stock.service.RoleService;
import com.itheima.stock.vo.req.PageReq;
import com.itheima.stock.vo.req.RoleUserIdReq;
import com.itheima.stock.vo.resp.PageResult;
import com.itheima.stock.vo.resp.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @ClassName RoleController
 * @Description TODO
 * @Author 久思
 * @Date 2023/10/8 9:29
 * @Version 1.0
 **/
@RestController
@RequestMapping("/api")
@CrossOrigin
public class RoleController {
    @Autowired
    private RoleService roleService;

    /**
     * 查询角色信息列表
     * @param pageReq
     * @return
     */
    @PostMapping("/roles")
    public R<PageResult<SysRole>> queryRoleInfo(@RequestBody PageReq pageReq) {
        return roleService.queryRoleInfo(pageReq);
    }

    /**
     * 修改用户关联的角色信息
     * @param req
     * @return
     */
    @PutMapping("/user/roles")
    public R<String> updateUserOrRole(@RequestBody RoleUserIdReq req) {
        return roleService.updateUserOrRole(req);
    }
}
